<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		<input id="fileupload" type="file" />
		<button id="clickBtn">点击</button>
		<textarea id="textcontent"></textarea>
		<script type="text/javascript">
			var fileBtn = document.getElementById("clickBtn");
			fileBtn.onclick = function(){
				var fileObj = document.getElementById("fileupload");
				console.log(fileObj.files);
				jsReadFiles(fileObj.files);
				// console.log(window.URL.createObjectURL(fileObj.files[0]))
				Readfile();
			}
			function jsReadFiles(files) {
				if (files.length) {
					var file = files[0];
					var reader = new FileReader(); //new一个FileReader实例
					if (/text+/.test(file.type)) { //判断文件类型，是不是text类型
						reader.onload = function() {
							document.getElementById("textcontent").innerHTML = this.result;
						}
						reader.readAsText(file);
					} else if (/image+/.test(file.type)) { //判断文件是不是imgage类型
						reader.onload = function() {
							$('body').append('<img src="' + this.result + '"/>');
						}
						reader.readAsDataURL(file);
					}
				}
			}
			var ForReading = 1;
			function Readfile(){
				var fso = new ActiveXObject("Scripting.FileSystemObject");
				var content = fso.OpenTextFile("G:\MyDocuments\WEB前端知识汇总\新建文本文档.txt",1);
				console.log(content);
			}
		</script>
	</body>
</html>
